package com.zcy.listener;

import com.espertech.esper.common.client.EventBean;
import com.espertech.esper.common.internal.event.bean.core.BeanEventBean;
import com.espertech.esper.runtime.client.EPRuntime;
import com.espertech.esper.runtime.client.EPStatement;
import com.espertech.esper.runtime.client.UpdateListener;
import lombok.extern.slf4j.Slf4j;

import java.util.Arrays;
import java.util.function.Consumer;

@Slf4j
public class BasicSelectListener implements UpdateListener {

    @Override
    public void update(EventBean[] newData, EventBean[] oldData, EPStatement epStatement, EPRuntime epRuntime) {
        if (newData != null && newData.length > 0) {
            Arrays.asList(newData).forEach(item -> {
                BeanEventBean mapEventBean = (BeanEventBean) item;
                log.info("-NewData amount is {} account is {}", mapEventBean.get("account"), mapEventBean.get("amount"));
            });
        }
    }
}
